﻿using FourGroups.Project;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
using test.demo.Model.WM仓储管理;
using wangyaxin.Qi;
using wangyaxin.Qi.Dto;

namespace wangyaxin.Web.QiDataController
{
    public class QiDataController : Controller
    {

        private readonly QiAppService _qiAppService;
        public QiDataController(QiAppService qiAppService)
        {
            _qiAppService = qiAppService;
        }
        /// <summary>
        /// 客户添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
       
        public async Task<IActionResult> AddClient(CreateClientDto input)
        {
            var a=await _qiAppService.AddClient(input);
            return Json(a);
        }


       

        /// <summary>
        /// 客户查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> GetClientShow(string clientCode = "", string clientName = "", int page = 1, int limit = 3)
        {
            var b = await _qiAppService.GetClientShow(clientCode, clientName, page, limit);
            return Json(b);
        }


        /// <summary>
        /// 客户反填
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>

        public async Task<IActionResult> UpdateClientById(UpdateClientDto input)
        {
            var c=await _qiAppService.UpdateClientById(input);
            return Json(c);
        }
        /// <summary>
        /// 客户删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
   
        public async Task<JsonResult> DelClient(int id)
        {
            var d=await _qiAppService.DelClient(id);
            return Json(d);
        }

        /// <summary>
        /// 客户显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult Mdclient()
        {
            return View();
        }
        /// <summary>
        /// 客户修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult UpdateClient()
        {
            return View();
        }
        /// <summary>
        /// 客户添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult AddClientIndex()
        {
            return View();
        }


        /// <summary>
        /// 仓库查询
        /// </summary>
        /// <param name="warehouseCode"></param>
        /// <param name="warehouseName"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public async Task<JsonResult> GetWareHouse(string warehouseCode = "", string warehouseName = "", int page = 1, int limit = 3)
        {
            var list = await _qiAppService.GetWareHouse(warehouseCode, warehouseName, page, limit);
            return Json(list);
        }
        /// <summary>
        /// 仓库添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> AddWareHouse(CreateWareHouseDto input)
        {
            var a = await _qiAppService.AddWareHouse(input);
            return Json(a);
        }
        /// <summary>
        /// 仓库修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> UpdateWareHouse(UpdateWareHouseDto input)
        {
            var a=await _qiAppService.UpdateWareHouse(input);
            return Json(a);
        }
        /// <summary>
        /// 仓库删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<JsonResult> DelWareHouse(int id)
        {
            var a=await _qiAppService.DelWareHouse(id);
            return Json(a);
        }

        /// <summary>
        /// 仓库显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult HouseShow()
        {
            return View();
        }
        /// <summary>
        /// 仓库添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult HouseAdd()
        {
            return View();
        }
        /// <summary>
        /// 仓库修改视图
        /// </summary>
        /// <returns></returns>
        public IActionResult HouseUpdate()
        {
            return View();
        }


        /// <summary>
        /// SN查询
        /// </summary>
        /// <returns></returns>
        public async Task<JsonResult> GetSnShow(string snCode = "", string itemCode = "", string itemName = "", string batchCode = "", int page = 1, int limit = 3)
        {
            var Sn = await _qiAppService.GetSnShow(snCode, itemName, itemName, batchCode, page, limit);
            return Json(Sn);
        }
        /// <summary>
        /// Sn添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> AddSn(CreateSnDto input)
        {
            var a = await _qiAppService.AddSn(input);
            return Json(a);
        }
        /// <summary>
        /// Sn修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> UpdateSn(UpdateSnDto input)
        {
            var a = await _qiAppService.UpdateSn(input);
            return Json(a);
        }
        /// <summary>
        /// Sn删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<JsonResult> DelSn(int id)
        {
            var a = await _qiAppService.DelSn(id);
            return Json(a);
        }
        /// <summary>
        /// SN显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult SNShow()
        {
            return View();
        }
        /// <summary>
        /// SN添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult SNAdd()
        {
            return View();
        }



        /// <summary>
        /// 生产领料查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> GetHeader(string issueCode = "", string issueName = "", string warehouseName = "", string issueDate = "", string status = "", int page = 1, int limit = 3)
        {
            var result = await _qiAppService.GetHeader(issueCode, issueName, warehouseName, issueDate, status, page, limit);
            return Json(result);
        }
        /// <summary>
        /// 生产领料添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> AddHeader(CreateHeaderDto input)
        {
            var a= await _qiAppService.AddHeader(input);
            return Json(a);
        }
        /// <summary>
        /// 生产领料修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<IActionResult> UpdateHeader(UpdateHeaderDto input)
        {
           var  a=await _qiAppService.UpdateHeader(input);
            return Json(a);
        }
        /// <summary>
        /// 生产领料删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<IActionResult> DelHeader(int id)
        {
            var  a= await _qiAppService.DelHeader(id);
            return Json(a);
        }

        /// <summary>
        /// 生产领料显示视图
        /// </summary>
        /// <returns></returns>
        public IActionResult HeaderShow()
        {
            return View();
        }
        /// <summary>
        /// 生产领料添加视图
        /// </summary>
        /// <returns></returns>
        public IActionResult HeaderAdd()
        {
            return View();
        }






    }
}
